package com.herench.jwt.model;


import com.herench.jwt.config.ResultStatus;

import java.io.Serializable;

/**
 * 自定义返回结果
 *
 * @author Squall
 * @create 14/03/2018
 * @since 1.0.0
 */

public class ResultModel implements Serializable {
    private static final long serialVersionUID = 8494989414288926017L;
    /**
     * 返回码
     */
    private int code;

    /**
     * 返回结果描述
     */
    private String message;

    /**
     * 返回内容
     */
    private Object content;

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getContent() {
        return content;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setContent(Object content) {
        this.content = content;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public ResultModel(int code, String message) {
        this.code = code;
        this.message = message;
        this.content = "";
    }

    public ResultModel(int code, String message, Object content) {
        this.code = code;
        this.message = message;
        this.content = content;
    }

    public ResultModel(ResultStatus status) {
        this.code = status.getCode();
        this.message = status.getMessage();
        this.content = "";

    }


    public ResultModel(ResultStatus status, Object content) {
        this.code = status.getCode();
        this.message = status.getMessage();
        this.content = content;
    }


    public static ResultModel ok(Object content) {
        return new ResultModel(ResultStatus.SUCCESS, content);
    }

    public static ResultModel ok() {
        return new ResultModel(ResultStatus.SUCCESS);
    }

    public static ResultModel error(ResultStatus status) {
        return new ResultModel(status);
    }


}
